export const mutations = {
  TOGGLE_THEME: "toggleTheme",
};

const isDarkTheme = localStorage.getItem("isDarkTheme") === "true";

export default {
  namespaced: true,
  state: () => ({
    isDarkTheme: isDarkTheme,
  }),
  mutations: {
    updateState: (state, obj) => {
      Object.keys(obj).forEach((key) => {
        state[key] = obj[key];
      });
    },
    toggleTheme: (state) => {
      const res = !state.isDarkTheme;
      state.isDarkTheme = res;
      localStorage.setItem("isDarkTheme", res);
    },
  },
};
